/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.DataTraveler.com.dal;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author curso
 */
public class Conexion {


    private static Conexion c;
    public static Connection con;

    private Conexion()
    {
        try {
            String url = "jdbc:derby://localhost:1527/stock_productos";
            String up = "admin";            
            Class.forName("org.apache.derby.jdbc.ClientDriver");
            con = DriverManager.getConnection(url, up, up);

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

   public static Conexion getConexion(){
            if (c == null){
             c = new Conexion();
            };

    return c;
   }
public ResultSet getResultSet(String sql) throws SQLException {
        PreparedStatement pstmt = null;
        pstmt = con.prepareStatement(sql.toString());
        pstmt.executeQuery();
        return pstmt.getResultSet();
    }

}


